home *** CD-ROM | disk | FTP | other *** search
/ AOL File Library: 4,401 to 4,500 / aol-file-protocol-4400-4401-to-4500.zip / AOLDLs / PDA-Newton Development / Newt 3.4 (develop apps,pkgs).sit / newt-devenv-34.sit / graphic0.nwt < prev    next >
Text File  |  1998-01-25  |  3KB  |  126 lines

  1. Notes
  2. {labels: 'NIL, viewFont: 10241} // nil=Unfiled, or specify a folder, e.g., 'Business.  remove viewFont for current Styles default
  3. //ERASE! in order to erase existing entries in this folder first
  4.  
  5. graphic0.nwt -- Sloup format
  6. 25 Jan 1998
  7. Copyright 1994-98 S. Weyer.  All Rights Reserved Worldwide.
  8. To be distributed only with NewtDevEnv
  9.  
  10. introductory Newt graphics examples
  11.  
  12. sources for: poly, poly2, polyspi, squiral, cCurve, house, rect
  13.  
  14. see graphic1.nwt for: squiral2 (interruptible version), dCurve,
  15. fractal, hilbert, fourNewts (multiple Newts), tree
  16.  
  17. see NewtTurT -- interactive tutorial for more description
  18.  
  19. To minimize text entry, use the Sloup utility and a terminal emulator to
  20. transfer this text file as paragraphs in the Notepad.  The folder in 2nd line
  21. is currently set on nil (Unfiled); select same folder in Newt to load.
  22. ----------
  23. poly2
  24. //:poly2 (5,80,360/5,0)
  25. //:poly2 (5,80,180-180/5,0)
  26. //:poly2 (times,dist,deg,90)
  27. func(nsides,len,ang,ang2)
  28. // poly with an extra turn at end for squiral & squiral2
  29. // also, ang precomputed & passed
  30. // assumes nsides already checked
  31. begin
  32.     local i;
  33.     for i:=1 to nsides
  34.     do begin
  35.         :go(len);
  36.         :turn(ang);
  37.         end;
  38.     :turn(ang2);
  39. end
  40. ----------
  41. poly
  42. //:poly (4,100)
  43. //:poly (times,dist)
  44. //local i; for i:=3 to times do :poly(i,dist)
  45. //:poly(Random(3,15),Random(10,20))
  46. func (nsides,len)
  47. if nsides>0
  48. then :poly2(nsides, len, 360/nsides, 0)
  49. else :beep()
  50. ----------
  51. squiral
  52. //:squiral (10,75)
  53. //:squiral (times,dist)
  54. //:addNewt('[[newt1,-55,75,1],[newt2,55,75,2],[newt3,55,-75,1],[newt4,-55,-75,2]],nil,nil,nil)
  55. //newt1:poly2(5,40,144,0)
  56. //:squiral (8,40)
  57. //:cCurve (6,4,0)
  58. func (num,len)
  59. // draw <num> squares
  60. // each of size <len>
  61. // after each, turn 360/num
  62. if num>0
  63. then begin
  64.     local i, ang2:=360/num;
  65.     for i:=1 to num
  66.     do :poly2 (4,len,90,ang2);
  67.     end
  68. else :beep()
  69. ----------
  70. cCurve
  71. //:cCurve (6,8,0)
  72. //:cCurve (8,4,0)
  73. //:cCurve (times,dist,deg)
  74. func(num,dist,deg)
  75. if num>0 // warning num>8 could take awhile...
  76. then begin // the double-recursion (not a simple "tail recursion")
  77.     :cCurve(num-1, dist, deg+45);
  78.     :cCurve(num-1, dist, deg-45);
  79.     end
  80. else begin // where the actual drawing occurs
  81.     :turnTo(deg);
  82.     :go(dist);
  83.     end
  84. ----------
  85. polyspi
  86. //:polyspi (100,10,89)
  87. //:polyspi (times,dist,deg)
  88. func(num,size,angle)
  89. begin
  90.     local i;
  91.     for i:=1 to num
  92.     do begin
  93.         :go(size);
  94.         :turn(angle);
  95.         size := size+1;
  96.         end;
  97. end
  98. ----------
  99. house
  100. //:house (dist)
  101. func(size)
  102. begin
  103.   local dht := size/4, dwid := size/8;
  104.   local wsize := dwid;
  105.   :poly(4,size);
  106.   :turn(90); :go(dht); :turn(-90);
  107.   :rect(dht,dwid); // door
  108.   :move(3*dht);
  109.   :poly(4,wsize); // window
  110.   :turn(90); :move(size/2); :turn(-90);
  111.   :poly(4,wsize); // window
  112. end
  113. ----------
  114. rect
  115. func(side1,side2)
  116. begin
  117.     local i;
  118.     for i:=1 to 2
  119.     do begin
  120.         :go(side1); :turn(90);
  121.         :go(side2); :turn(90);
  122.         end;
  123. end
  124. ----------
  125. BYE!
  126.